package me.maiz.babyisland.web.advice;

import me.maiz.babyisland.service.ICategoryService;
import me.maiz.babyisland.service.info.CategoryInfo;
import lombok.extern.slf4j.Slf4j;
import me.maiz.babyisland.service.ICategoryService;
import me.maiz.babyisland.service.info.CategoryInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ModelAttribute;

import java.util.List;

@ControllerAdvice
@Slf4j
public class DataAdvice {

    @Autowired
    private ICategoryService categoryService;


    @ModelAttribute(name = "categories")
    public List<CategoryInfo> categories(){
        log.info("获取分类数据");
        List<CategoryInfo> categories = categoryService.getAllCategoryInfo();
        return categories;
    }


}
